<?php

function ip_login_message( $message ) {
    if ( empty($message) ){
        if (empty($_REQUEST['message'])) {
            return '';
        }
        return $_REQUEST['message'];
    } else {
        return $message;
    }
}
add_filter( 'login_message', 'ip_login_message' );

add_action( 'after_setup_theme', 'ip_add_roles' );
function ip_add_roles() {
    add_role( 'illuminare_editor', 'Illuminare Editor' );
}

//Add filter so that only orders that are processing or completed will show up 
add_filter( 'woocommerce_reports_order_statuses', 'wc_custom_report_order_statuses_1' );
function wc_custom_report_order_statuses_1( $statuses ) {
    $statuses = array( 'processing', 'completed' );
    return $statuses;
}

//Add filter so that virtual items do not include the quantity selector.
add_filter( 'woocommerce_is_sold_individually', 'wc_remove_quantity', 10, 2 );
function wc_remove_quantity( $return, $product ) {
    return $return || $product->is_downloadable();
}

//custom functions to add shipping_account to the dropdown of custom fields.
add_action( 'admin_footer-post-new.php', 'wpse_98269_script' );
add_action( 'admin_footer-post.php', 'wpse_98269_script' );

function wpse_98269_script()
{
    if ( ! isset ( $GLOBALS['post'] ) )
        return;

    $post_type = get_post_type( $GLOBALS['post'] );

    if ( ! post_type_supports( $post_type, 'custom-fields' ) )
        return;
    ?>
<script>
    if ( jQuery( "[value='shipping_account']" ).length < 1 ) // avoid duplication
        jQuery( "#metakeyselect").append( "<option value='shipping_account'>shipping_account</option>" );
</script>
    <?php
}
?>